#include<iostream>
using namespace std;
const int N = 1e3 + 10;
int n;
int arr[N];
int f[N][N][11];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	f[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			for (int k = 0; k < 11; k++) {
				f[i][j][k] += f[i - 1][j - 1][(k - arr[i] % 11 + 11) % 11];
				f[i][j][k] += f[i - 1][j][k];
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			ans += f[i][j][0];
		}
	}
	cout << ans << endl;
	return 0;
}
